package com.shuwang.goods.until;

import java.util.Stack;

public class CodeBuilder
{
	public final static String createCode()
	{
		//获取当前系统时间
		long currentTime = System.currentTimeMillis();
		String code = ten2sixtytwo(currentTime);
		return code;
	}

	private static char[] charSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();


	public static String ten2sixtytwo(long number){
		Long rest=number;
		Stack<Character> stack=new Stack<Character>();
		StringBuilder result=new StringBuilder(0);
		while(rest!=0){
			stack.add(charSet[new Long((rest-(rest/62)*62)).intValue()]);
			rest=rest/62;
		}
		for(;!stack.isEmpty();){
			result.append(stack.pop());
		}
		//
		return result.toString();
	}

	// 10 -- 62
	public static String ten2sixtytwo(long number, int length){
		String result = ten2sixtytwo(number);
		int result_length = result.length();
		StringBuilder temp0 = new StringBuilder();
		for(int i = 0; i < length - result_length; i++){
			temp0.append('0');
		}
		//
		return temp0.toString() + result;
	}

}